<?php namespace Admin\Controller; 

use Hdphp\Controller\Controller;

//后台登陆
class LoginController extends Controller{

//  后台登陆首页
    public function index(){
      if(IS_POST){
      	$username=Q('post.username');
		$password=md5(Q('post.password'));
		$model=new \Common\Model\Adminuser;
		$data=$model->where("username='{$username}'")->find();
		if(!$data) View::error('用户名或密码错误');
		if($data['password']!=$password) View::error('用户名或密码错误');
		$_SESSION['uid']=$data['uid']; $_SESSION['husername']=$data['username'];
		View::success('登陆成功',U('Index/index'));
      }
       View::make();
    }
//	退出
	public function out(){
		session_unset();
		session_destroy();
		go(U('Index/index'));
	}
	
	
	
	
}
